%{
    This file is part of StemCellQC, a video bioinformatics software
    toolkit for analysis of phase contrast microscopy videos.
    Copyright 2013-2015 Vincent On. [vincenton001-at-gmail.com]

    StemCellQC is free software: you can redistribute it and/or 
    modify it under the terms of the GNU General Public License as 
    published by the Free Software Foundation, either version 3 of the 
    License, or (at your option) any later version.

    StemCellQC is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with StemCellQC.  If not, see <http://www.gnu.org/licenses/>.
%}

function fix_skipped_frame( index )

global mov

%fix skipped frame by averaging each feature
if index == 2
    mov(index - 1).features = mov(index).features;
else

    mov(index - 1).features{ 1 } = (mov(index).features{ 1 } + mov(index - 2).features{ 1 }) / 2;
    mov(index - 1).features{ 2 } = (mov(index).features{ 2 } + mov(index - 2).features{ 2 }) / 2;
    mov(index - 1).features{ 3 } = (mov(index).features{ 3 } + mov(index - 2).features{ 3 }) / 2;
    mov(index - 1).features{ 4 } = (mov(index).features{ 4 } + mov(index - 2).features{ 4 }) / 2;
    mov(index - 1).features{ 5 } = (mov(index).features{ 5 } + mov(index - 2).features{ 5 }) / 2;
    mov(index - 1).features{ 6 } = (mov(index).features{ 6 } + mov(index - 2).features{ 6 }) / 2;
    mov(index - 1).features{ 7 } = (mov(index).features{ 7 } + mov(index - 2).features{ 7 }) / 2;
    mov(index - 1).features{ 8 } = (mov(index).features{ 8 } + mov(index - 2).features{ 8 }) / 2;
    mov(index - 1).features{ 9 } = (mov(index).features{ 9 } + mov(index - 2).features{ 9 }) / 2;
    mov(index - 1).features{ 10 } = (mov(index).features{ 10 } + mov(index - 2).features{ 10 }) / 2;
    mov(index - 1).features{ 11 } = mov(index).features{ 11 };
    mov(index - 1).features{ 12 } = (mov(index).features{ 12 } + mov(index - 2).features{ 12 }) / 2;
    mov(index - 1).features{ 13 } = (mov(index).features{ 13 } + mov(index - 2).features{ 13 }) / 2;
    mov(index - 1).features{ 14 } = (mov(index).features{ 14 } + mov(index - 2).features{ 14 }) / 2;
    mov(index - 1).features{ 15 } = (mov(index).features{ 15 } + mov(index - 2).features{ 15 }) / 2;
    mov(index - 1).features{ 16 } = (mov(index).features{ 16 } + mov(index - 2).features{ 16 }) / 2;
    mov(index - 1).features{ 17 } = (mov(index).features{ 17 } + mov(index - 2).features{ 17 }) / 2;
    mov(index - 1).features{ 18 } = (mov(index).features{ 18 } + mov(index - 2).features{ 18 }) / 2;
    mov(index - 1).features{ 19 } = (mov(index).features{ 19 } + mov(index - 2).features{ 19 }) / 2;
    mov(index - 1).features{ 20 } = (mov(index).features{ 20 } + mov(index - 2).features{ 20 }) / 2;
end
